// needs C_STR_EXTERNAL_PATH

Ext.define('AmpleHarvest.objects.groups.cGroupManager',
{
	extend			: 'Ext.panel.Panel',
	alias			: 'widget.ampleharvest-objects-groups-cgroupmanager',
//	id				: 'topLevelContent',
	requires		:
	[
			"AmpleHarvest.objects.groups.window.cGroupMembers",
			"AmpleHarvest.objects.groups.window.cGroupModules"
	],
	layout			: 'border',
	
	initComponent	: function()
	{
		var obj_This = this;

		this.m_bool_admin = false;
		this.get_authorization();
		
		this.m_obj_MemberView = Ext.create(
				"AmpleHarvest.objects.groups.window.cGroupMembers",
				{
					region			: "west",
					flex			: 2,
					m_str_groupId 	: this.m_str_groupId,
					m_bool_admin	: 'wtf'
				}
		);
		
		this.m_obj_ModuleView = Ext.create(
				"AmpleHarvest.objects.groups.window.cGroupModules",
				{
					region			: "center",
					flex			: 8,
					m_str_groupId 	: this.m_str_groupId,
					m_bool_admin	: this.m_bool_admin
				}
		);
		
		
		this.items =
			[
				this.m_obj_MemberView, 
				this.m_obj_ModuleView
			]
	
		this.callParent();
	},
	
	get_authorization	: function()
	{
		Ext.Ajax.request(
		{
			url		: m_obj_AmpleHarvest_ViewPort.configObject.C_STR_EXTERNAL_PATH+'/rest/security/group.php',
			method	: 'GET',
			params	:
			{
				id		: obj_config.user.id,
				group	: this.m_str_groupId
			},
			timeout	: 100000,
			success	: function(response)
			{
				$obj_response = Ext.decode(response.responseText);
				if($obj_response.success)
					{
						this.add_admin_options();
					}
			},
			failure	: function(obj_Response)
			{
				console.log('There was a network problem retrieving your admin status');
				console.log(obj_Response);
				
			},

			scope	: this
		})		
	},
	
	add_admin_options	: function()
	{
		this.m_obj_MemberView.add_admin_options();
		this.m_obj_ModuleView.add_admin_options();
	}
});